package com.zyb;

import com.zyb.config.SpringConfig;
import com.zyb.dao.BookDao;
import com.zyb.service.BookService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;

public class AppForDI {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new
                AnnotationConfigApplicationContext(SpringConfig.class);
        DataSource dataSource = ctx.getBean(DataSource.class);
        System.out.println(dataSource);

//        BookService bookService = ctx.getBean(BookService.class);
//        System.out.println(bookService);
//
//        BookDao bookDao = ctx.getBean(BookDao.class);
//        System.out.println(bookDao);

        ctx.close(); //关闭容器
    }
}
